<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text"  id="name"  />
		<input type="button" onclick="Guess()" id="cai" value="猜" />
		<span id="resultId"></span>
		
		<script type="text/javascript">
			var random = parseInt(Math.random()*100 + 1);
			console.log(random);
		
			function Guess(){
				var num = document.getElementById("name").value;
				
				if (isNaN(num)) {
				
					var resultSpan = document.getElementById("resultId");
					var result = "输入的不是数字";
					resultSpan.innerHTML = result;
			}else if (num < 0) {
					console.log("请输入正数");
					var resultSpan = document.getElementById("resultId");
					var result = "请输入正数";
					resultSpan.innerHTML = result;
				}else{
					var resultSpan = document.getElementById("resultId");
					if(parseInt(num) > parseInt(random)){
						resultSpan.innerHTML ="猜大了";
					}
					else if (parseInt(num) < parseInt(random)){
						resultSpan.innerHTML ="猜小了";
					}else{
						resultSpan.innerHTML ="猜对了";
					}
				}
			}
		</script>
	</body>
</html>
